package com.lims.service.common.impl;

import java.util.List;

import javax.management.loading.PrivateClassLoader;

import com.lims.dao.common.IEnPartyDAO;
import com.lims.dao.common.IProjectDAO;
import com.lims.dao.common.ISampleDAO;
import com.lims.po.common.EnParty;
import com.lims.po.common.Project;
import com.lims.po.common.Sample;
import com.lims.po.common.TestOfProject;
import com.lims.service.common.IProjectService;
import com.lims.service.common.ITestOfProjectService;



public class ProjectServiceImpl  implements IProjectService {
	private IProjectDAO projectDAO;
	private ITestOfProjectService testOfProjectService;
	private IEnPartyDAO enPartyDAO;
	private ISampleDAO sampleDAO;
	public boolean deleteProject(Project project) {
		return projectDAO.deleteProject(project);
	}

	public boolean deleteProjectById(int pid) {
		return projectDAO.deleteProjectById(pid);
	}

	public boolean saveProject(Project project) {
		return projectDAO.saveProject(project);
	}
	public boolean saveProject(Project project,Sample sample,EnParty enParty,List<TestOfProject> testOfProjects) {
//		sampleDAO.updateSample(sample);
//		System.out.println("save getEnParty:"+sample.getPid());
//		enPartyDAO.updateEnParty(enParty);
//		System.out.println(" before save project:");
		project.setEnParty(enParty);
		project.setSample(sample);
		boolean flag=projectDAO.saveProject(project);
		return flag&&testOfProjectService.updateProjectTestItem(project.getPid(), testOfProjects);
	}
	public List<Project> selectAll() {
		return projectDAO.selectAll();
	}

	public boolean selectProjectByProjectTitle(String projectTitle) {
		return projectDAO.selectProjectByProjectTitle(projectTitle);
	}

	public boolean updateProject(Project project) {
		return projectDAO.updateProject(project);
	}
	public Project selectProjectById(int pid) {
		return projectDAO.selectProjectById(pid);
	}

	public IProjectDAO getProjectDAO() {
		return projectDAO;
	}

	public void setProjectDAO(IProjectDAO projectDAO) {
		this.projectDAO = projectDAO;
	}

	public ITestOfProjectService getTestOfProjectService() {
		return testOfProjectService;
	}

	public void setTestOfProjectService(ITestOfProjectService testOfProjectService) {
		this.testOfProjectService = testOfProjectService;
	}

	public IEnPartyDAO getEnPartyDAO() {
		return enPartyDAO;
	}

	public void setEnPartyDAO(IEnPartyDAO enPartyDAO) {
		this.enPartyDAO = enPartyDAO;
	}

	public ISampleDAO getSampleDAO() {
		return sampleDAO;
	}

	public void setSampleDAO(ISampleDAO sampleDAO) {
		this.sampleDAO = sampleDAO;
	}
}
